<template>
  <a-form-item :name="props.formNamePath?.concat(['outLink', 'linkUrl']) || []" :label="formItem.label"
    :rules="[formItem.rule]" :extra="formItem.extra" :style="{ marginLeft: formItem.marginLeft + 'px' }"
    :class="formItem.associated ? 'form-a-radio-group_associated' : 'form-a-number-input'">
    <div>
      <span class="beforeText" v-if="formItem.beforeText">{{ formItem.beforeText }}</span>
      <a-input v-model:value="formItem.value.linkUrl" :disabled="formItem.disabled"
        :placeholder="formItem.placeholder" style="width:''px; padding-left: 12px;" :show-count="formItem.showCount"
        @change="changeName" :maxlength="formItem.maxCount" allow-clear />
      <div :style="{ 'margin-top': '8px' }">
        <a-form-item-rest>
          <a-radio-group :disabled="formItem.disabled" v-model:value="(formItem.value.newWindow)">
            <template v-for="(options, index_options) in formItem.options" :key="index_options">
              <a-radio :value="formItem.isBoolean ? (index_options ? false : true) : (+index_options + 1)">
                {{ options.label ? options.label : options }}
              </a-radio>
            </template>
          </a-radio-group>
        </a-form-item-rest>
      </div>
    </div>
    <div class="help-msg" v-if="formItem.helpMsg">
      {{ formItem.helpMsg }}
    </div>

  </a-form-item>
</template>

<script lang="ts" setup>
import { ref, reactive, watch, computed } from "vue"
import { dataSourceType } from "@/type.d";
import { useColumnItem } from '@/components/draggable/hooks/useColumnModel';
const emit = defineEmits(['changeName'])
//props
const props = defineProps({
  formItem: {
    type: Object,
    default: {} as dataSourceType
  },
  formNamePath: [] as any[],
})
let formItem: any = ref(props.formItem as any);
useColumnItem(computed(() => props.formItem), formItem)

const changeName = (e: any) => {
  formItem.value = e.target.value;
  emit('changeName', formItem.value)
};

</script>

<style lang="less" scoped>
.help-msg {
  margin-top: 8px;
  font-size: 12px;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.45);
  line-height: 20px;
}
</style>